package _2022.hot100._155_最小栈;

import java.util.Deque;
import java.util.LinkedList;

/**
 * @author： YHSimon
 * @date： 2022-05-06 11:25
 */
public class MinStack {
    Deque<Integer>  xStack;
    Deque<Integer>  minStack;
    public MinStack(){
        xStack=new LinkedList<>();
        minStack=new LinkedList<>();
        minStack.push(Integer.MAX_VALUE);
    }

    public void push(int x){
        xStack.push(x);
        minStack.push(Math.min(minStack.peek(), x));
    }

    public void pop(){
        xStack.pop();
        minStack.pop();
    }

    public int top(){
        return xStack.peek();
    }

    public int getMin(){
        return minStack.peek();
    }
}
